<template>
<slot :controller="controller" :store="store" :model="model">
    <component
        :is="IBIZOrderDetailGridView"
        name="IBIZOrderDetailGridView"
        openType="EMBED"
        :context="store.context"
        :viewParams="store.viewParams"
        :class="[classNames,'view-container2']"
        :isLoadDefault="false"
        @view-init="(name: string, data: any) => handleCtrlInit(controller, name, data)"
        @view-action="(name: string, action: string, data: IParam[]) => handleCtrlAction(controller, name, action, data)"
        @view-destroy="(name: string, data: any) => { handleCtrlDestroy(controller, name, data); }">
    </component>    
</slot>
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@TABVIEWPANEL}}-tab-view-panel/{{spinalCase ctrl.codeName}}-tab-view-panel-base.vue.hbs生成
import { model } from "./tab-exp-viewtabviewpanel-2-tab-view-panel-model";
import IBIZOrderDetailGridView from '@views/ibiz-order-detail-grid-view/ibiz-order-detail-grid-view.vue';
import { useProps, useBasic, useAction, useController } from './tab-exp-viewtabviewpanel-2-tab-view-panel-hook';
import { TabViewPanelActionType, ITabViewPanelAbility, ITabViewPanelStore, IParam } from "@/core/interface";

// 输入参数
const props = defineProps(useProps());

// 基础数据
const { 
    model,
    controlID, 
    getClassNames, 
    useNavParamsBind,
    useEventBind, 
    handleCtrlDestroy,
    handleCtrlInit, 
    handleCtrlAction,
} = useBasic(props);

const emit = defineEmits<{
    (event: 'ctrl-action', name: string, action: TabViewPanelActionType, data: IParam[]): void;
    (event: 'ctrl-init', name: string, data: ITabViewPanelAbility): void;
    (event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
  return getClassNames(props);
});

const controller = useController(props, evt, { controlID });

useNavParamsBind(controller, props);

const store: ITabViewPanelStore = controller.getStore();

onMounted(() => {
    controller.ctrlMounted();
});

onUnmounted(() => {
    controller.ctrlDestroy();
})
</script>
